    var map = new AMap.Map('container', {
        resizeEnable: true,
        center: [113.706843, 34.762182],
        zoom: 9,
        mapStyle: 'amap://styles/434d22c66ce28f34056207589740a540'
    });
    map.plugin('AMap.Geolocation', function() {
        var geolocation = new AMap.Geolocation({
            // 是否使用高精度定位，默认：true
            enableHighAccuracy: true,
            // 设置定位超时时间，默认：无穷大
            timeout: 3000,
            // 定位按钮的停靠位置的偏移量，默认：Pixel(10, 20)
            buttonOffset: new AMap.Pixel(10, 20),
            //  定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            zoomToAccuracy: true,
            //  定位按钮的排放位置,  RB表示右下
            //buttonPosition: 'RB'
        })

        geolocation.getCurrentPosition()
        AMap.event.addListener(geolocation, 'complete', onComplete)
        AMap.event.addListener(geolocation, 'error', onError)

        function onComplete(data) {
            // data是具体的定位信息
            addressCode = data.addressComponent.adcode;

        }

        function onError(data) {
            // 定位出错
            //console.log(data);
            addressCode = "410103";
        }
    })
    var addressCode = "";
    // 加载天气参数
    setTimeout("weatherTime()", 2000);

    function weatherTime() {
        wPlugin.init(map, addressCode, function(res) {
            if (addressCode == "") {
                addressCode = "410103";
            }
            var _result = res;
            var urlPrefix = 'http://111.7.172.183:19082';
            $("#weatherIcon").attr("src", urlPrefix + _result.weatherIcon);
            $("#tempPanel").text(_result.temperature);
            $("#wind").find(".w").html('<span>' + _result.windDirection + '</span>' + _result.windPowerText);
            $("#wind").find(".wind-switch").html('<span>' + _result.humidity + '</span>' + _result.airQualText);
            var _tme = setInterval(function() {
                var _ret = wPlugin.returnDate(' : ', ' / ');
                $("#dateTime").html('<p class="time">' + _ret.time + '</p><p class="date">' + _ret.date + '</p>');
            }, 1000);
        });
    }
    $(".mapadd").on("click", function() {
        var n = map.getZoom();
        n++
        map.setZoom(n);
    })
    $(".mapreduce").on("click", function() {
        var n = map.getZoom();
        n--
        map.setZoom(n);
    })

    //树结构在线设备参数设定(ajax异步请求数据)
    var setting = {
        async: {
            enable: true,
            url: ctx + "monitorCenter/getVehicleTree", //  getVehicleTree_hld
            dataType: "json",
            //返回的数据过滤器
            dataFilter: filter
        },
        view: {
            selectedMulti: false,
            showLine: false
        },
        check: {
            enable: true,
            chkStyle: "checkbox",
            chkboxType: { "Y": "s", "N": "ps" }
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "ID",
                pIdKey: "PID",
                rootPId: "0"
            },
            key: {
                name: "NAME"
            }
        },
        callback: {
            onCheck: onCheck,
            onAsyncSuccess: zTreeOnAsyncSuccess,
            onClick: zTreeOnClick
        }
    };

    function getAllChildrenNodes(treeNode) {
        if (treeNode.isParent) {
            var childrenNodes = treeNode.children;
            if (childrenNodes) {
                for (var i = 0; i < childrenNodes.length; i++) {

                    if (childrenNodes[i].TYPE == "org") {
                        getAllChildrenNodes(childrenNodes[i]);
                    } else {
                        if (childrenNodes[i].PID) {
                            checkedMap.put(childrenNodes[i].ID, "1");
                        }
                        var lnglatTemp = childrenNodes[i].l;
                        var lnglatArray = lnglatTemp.split(",");
                        var icon = ctx + "img/markercar0-6-1.png";
                        if (childrenNodes[i].line == '1') {
                            icon = ctx + "img/markercar0-6.png";
                        }
                        var angle = parseInt(childrenNodes[i].AZ);
                        var marker = new AMap.Marker({
                            icon: icon,
                            position: lnglatArray,
                            offset: new AMap.Pixel(3, -23),
                            title: childrenNodes[i].NAME
                        })
                        marker.setExtData(childrenNodes[i].ID)

                        marker.on('click', function(e) {
                            openGDInfo(e.target.getExtData(), e.lnglat, true)
                        })
                        markers.put(childrenNodes[i].ID, marker);

                    }
                }
            }
        }
    }
    //ztree点击事件
    function zTreeOnClick(event, treeId, treeNode) {
        if (treeNode.TYPE == "org") {

        } else {
            layer.closeAll()
            var id = treeNode.ID;
            infoWindow_id = id;
            infoWindow.close();
            $('#removeTrail').click()
            var marker = markers.get(id)
            if (marker) {
                openGDInfo(marker.getExtData(), treeNode, true)
            } else {
                if (treeNode.pId) {
                    layer.msg("该车辆没有定位信息！")
                }
            }
        }

    }
    //请求成功后的数据过滤函数
    function filter(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        console.log(childNodes, 2210)
        for (var i = 0, l = childNodes.length; i < l; i++) {
            var icon = ctx + "img/chongdianzhuang-4.png";
            if (childNodes[i].TYPE != 'org') {
                if (childNodes[i].line == '1') {
                    icon = ctx + "img/chongdianzhuang-4.png";
                }
                childNodes[i].icon = icon;
            }
        }
        return childNodes;
    }
    var checkedMap = new HashMap()
    var webNodes;
    //ztree加载完成事件
    function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
        treeObj = $.fn.zTree.getZTreeObj(treeId);
        var nodes = treeObj.getNodes();   
        if (nodes.length > 0) {    
            for (var i = 0; i < nodes.length; i++) {     
                treeObj.expandNode(nodes[i], true, false, false); //默认展开第一级节点
             }
        }
        webNodes = nodes;
        treeObj.checkAllNodes(true);
        var nodes = treeObj.getCheckedNodes(true);
        console.log(nodes,120)
        for (index in nodes) {
            if (nodes[index].PID) {
                checkedMap.put(nodes[index].ID, "1");
            }
            if (nodes[index].TYPE != 'org') {
                var lnglatTemp = nodes[index].l;
                var lnglatArray = lnglatTemp.split(",");
                var icon = ctx + "img/cdzicon.png";
                if (nodes[index].line == '1') {
                    icon = ctx + "img/cdzicon.png";
                }
                var angle = parseInt(nodes[index].AZ);
                var contMarkHtml="";
                if(nodes[index].type=="直流"){
                    contMarkHtml =  '<div class="iconmark"><img src="' + icon + '"/><div><div class="cdqnum clearfix"><div class="zlCdzNum ">'+nodes[index].zlonline+'/'+nodes[index].zlstakeCount+'</div></div>';
                }
                if(nodes[index].type=="交流"){
                    contMarkHtml =  '<div class="iconmark"><img src="' + icon + '"/><div><div class="cdqnum clearfix"><div class="jlCdzNum ">'+nodes[index].jlonline+'/'+nodes[index].jlstakeCount+'</div></div>';
                }
                if(nodes[index].type=="混合"){
                    contMarkHtml =  '<div class="iconmark"><img src="' + icon + '"/><div><div class="cdqnum clearfix"><div class="zlCdzNum ">'+nodes[index].zlonline+'/'+nodes[index].zlstakeCount+'</div><div class="jlCdzNum ">'+nodes[index].jlonline+'/'+nodes[index].jlstakeCount+'</div></div>';
                }
                var marker = new AMap.Marker({
                    content: contMarkHtml,
                    position: lnglatArray,
                    offset: new AMap.Pixel(-33, -33),
                    title: nodes[index].NAME
                })
                marker.setExtData(nodes[index].ID)

                marker.on('click', function(e) {
                    openGDInfo(e.target.getExtData(), e.lnglat, true)
                })
                markers.put(nodes[index].ID, marker);
            }
        }
        map.setZoom(9);
        map.setCenter([113.639294, 34.75298]);
        cluster = new AMap.MarkerClusterer(map, markers.values(), { gridSize: 50, maxZoom: 12 });
        //setTimeout("refreshMarker()",5000)
        data = null;
    }
    //ztree check选中/取消事件
    function onCheck(event, treeId, node) {
        var nodes = treeObj.getCheckedNodes(true);
        if (!node.pId) {
            var checkedMap_new = new HashMap()
            for (index in nodes) {
                if (nodes[index].pId) {
                    checkedMap_new.put(nodes[index].id, "1");
                }
            }
            checkedMap = checkedMap_new
        } else {
            if (node.checked) {
                checkedMap.put(node.id, "1")
            } else {
                checkedMap.remove(node.id)
            }
        }
        //refreshMarker_tree()
    }

    var onlineArr = [];
    var offlineArr = [];
    var AllCarsArr = [];

    function getChildrenNodes(treeNode) {
        if (treeNode.isParent) {
            var childrenNodes = treeNode.children;
            if (childrenNodes) {
                for (var i = 0; i < childrenNodes.length; i++) {
                    if (childrenNodes[i].TYPE == "org") {
                        getChildrenNodes(childrenNodes[i]);
                    } else {
                        if (childrenNodes[i].line == '1') {
                            onlineArr.push(childrenNodes[i]);
                        } else {
                            offlineArr.push(childrenNodes[i]);
                        }
                        AllCarsArr.push(childrenNodes[i]);
                    }
                }
            }
        }
    }

    function count_list() {

    }
    $('#leftTree').height($(window).height()-110)
    $.fn.zTree.init($('#leftTree'), setting);
    //获取右侧全部车辆信息生成marker，使用点汇聚
    var cluster
    setInterval("refeshNodes()", 5000);
    function refeshNodes() {
        var nodes = treeObj.getCheckedNodes(true);
        if (nodes.length > 0) {
            for (var i = 0; i < nodes.length; i++) {
                if (nodes[i].TYPE != 'org') {
                    var timestamp = nodes[i].lt;
                    var dateOld = new Date(timestamp);
                    var timeOld = dateOld.getTime();
                    var timeNew = new Date().getTime();
                    var lnglatArray = nodes[i].l.split(",");
                    if (timeNew - timeOld > 120000) {
                        nodes[i].icon = ctx + "img/markercar0-6-1.png";
                        nodes[i].line = '0';
                        var icon_refesh_1 = ctx + "img/cdzicon.png";
                        var marker = markers.get(nodes[i].ID);
                        if (marker.getIcon() != icon_refesh_1) {
                            marker.setIcon(ctx + "img/cdzicon.png");
                        }
                        if (infoWindow.getIsOpen() && nodes[i].ID == infoWindow_id) {
                            $("#onlineSpan").html("离线");
                            $("#infoWindow_isCarried").html("关闭");
                            var diffTime = timeNew - timeOld;
                            $("#infoWindow_driverName").html(formatDuring(diffTime));
                        }
                        treeObj.updateNode(nodes[i]);
                    } else {

                    }
                }
            }
        }
    }

    function formatDuring(mss) {
        var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
        return hours + "时 " + minutes + "分 ";
    }

    //全局变量存储右侧marker
    var markers = new HashMap()
        //获取地图marker

    //地图缩放大小
    var zoomSize = 10;
    var geocoder;
    AMap.service('AMap.Geocoder', function() {
        geocoder = new AMap.Geocoder({
            city: "全国"
        });
    });
    //5s刷新右侧marker图标
    function refreshMarker() {
        if (trail_flag && map.getZoom() > 13) {
            console.log(new Date())
            $.ajax({
                    url: ctx + 'monitorCenter/getVehicleTree',
                    type: 'post',
                    data: { isonline: isonline },
                    async: false,
                    dataType: 'json',
                    complete: function(XHR, TS) {
                        XHR = null;
                    },
                    success: function(data) {
                        var clearMarkers = []
                        var addMarkers = []
                        for (index in data) {
                            var id = data[index].id;
                            var marker = markers.get(id)
                            if (checkedMap.get(id)) {
                                if (marker) {
                                    marker.setPosition(data[index].l)
                                    marker.setIcon(ctx + "img/markercar0-6.png");
                                } else {
                                    marker = new AMap.Marker({
                                        icon: ctx + "img/markercar0-6.png",
                                        position: data[index].l,
                                        offset: new AMap.Pixel(-15, -15),
                                        title: data[index].p
                                    })
                                    marker.setExtData(data[index].id)
                                    marker.on('click', function(e) {
                                        openGDInfo(e.target.getExtData(), e.lnglat, true)
                                    })
                                    markers.put(id, marker);
                                    addMarkers.push(marker)
                                }
                            } else {
                                if (marker) {
                                    markers.remove(id)
                                    clearMarkers.push(marker)
                                }
                            }
                        }
                        //判断infoWindow是否打开，是否进行数据刷新
                        if (infoWindow.getIsOpen()) {
                            var info = markers.get(infoWindow_id)
                            openGDInfo_refresh(info.getExtData(), info.getPosition())
                        }
                        // openGDInfo(info.id,info.position,false)
                        cluster.removeMarkers(clearMarkers)
                        cluster.addMarkers(addMarkers)
                            //setTimeout("refreshMarker()",5000)
                        data = null
                    }
                })
                //同步ztree与右侧图标在线状态
            var nodes = treeObj.getNodesByParam("level", "1", null);
            for (index in nodes) {
                var node = nodes[index]
                var marker = markers.get(node.id)
                if (marker && node.icon != marker.getIcon()) {
                    node.icon = marker.getIcon()
                    treeObj.updateNode(node)
                }
            }
        } else {
            //setTimeout("refreshMarker()",5000)
        }

    }
    //右侧进行check选中操做时刷新右侧marker
    function refreshMarker_tree() {
        if (cluster) {
            $.ajax({
                url: ctx + 'monitorCenter/getVehicleTree',
                type: 'post',
                async: false,
                dataType: 'json',
                complete: function(XHR, TS) {
                    XHR = null;
                },
                success: function(data) {
                    var clearMarkers = []
                    var addMarkers = []
                    for (index in data) {
                        var id = data[index].id;
                        var marker = markers.get(id)
                        if (checkedMap.get(id)) {
                            if (marker) {
                                marker.setPosition(data[index].l)
                            } else {
                                marker = new AMap.Marker({
                                    icon: styleArray[data[index].i],
                                    position: data[index].l,
                                    offset: new AMap.Pixel(-15, -15),
                                    title: data[index].p
                                })
                                marker.setExtData(data[index].id)
                                marker.on('click', function(e) {
                                    openGDInfo(e.target.getExtData(), e.lnglat, true)
                                })
                                markers.put(id, marker);
                                addMarkers.push(marker)
                            }
                        } else {
                            if (marker) {
                                markers.remove(id)
                                clearMarkers.push(marker)
                            }
                        }
                    }
                    cluster.removeMarkers(clearMarkers)
                    cluster.addMarkers(addMarkers)
                    data = null
                }
            })
        }
    }
    //第一次打开infoWindow
    var infoWindow_id
    var treeObj;

    function openGDInfo(id, node, flag) { //点击mark事件
        infoWindow_id = ""
        var tnode = treeObj.getNodeByParam("ID", id, null);
        var parentNode = tnode.getParentNode();
        var companyName = parentNode.NAME;
        treeObj.selectNode(tnode);
        console.log("打开infoWindow");
        var address = ""
        $.ajax({
            url: ctx + 'monitorCenter/getBusPopInfo',
            type: 'post',
            ansyc: false,
            data: { id: id },
            dataType: 'json',
            complete: function(XHR, TS) {
                XHR = null;
            },
            success: function(data) {
                console.log(data, 1021)
                data = data.data;
                var line = data.line;
                var as = data.as;
                if (line == '1') {
                    line = '在线';
                } else {
                    line = '离线';
                    var dateOld = new Date(data.lt);
                    var timeOld = dateOld.getTime();
                    var timeNew = new Date().getTime();
                    var diffTime = timeNew - timeOld;
                    as = formatDuring(diffTime);
                }
                //  判断是否需要按钮置灰
                //解析经纬度
                var llt = new AMap.LngLat(data.lng, data.lat)
                geocoder.getAddress(llt, function(status, result) {
                    if (status === 'complete' && result.info === 'OK') {
                        address = result.regeocode.formattedAddress;
                    } else {
                        address = '地址解析失败'
                        layer.msg('地址解析失败')
                    }
                    var mContent = '<div class="infowdz"><div class="infowdz_top clearfix"> <div class="infowdz_top_headurl"><img src="/img/cdq.png" /> </div> <div class="infoWhead"> <div class="infoWheadName">'+data.name+'</div> <div class="infoWheadNum">编号：'+data.num+' <div class="infoWheadtype">'+data.type+'站</div></div>  </div> </div>';
                        if(data.type=="直流"){
                            mContent  += '<div class="infowdz_zlbox clearfix"> <div class="infowdz_zlboxL"><div>站点类型：'+data.type+' </div><div>充电枪数：' + data.zlstakeCount +' </div> </div> <div class="infowdz_zlboxR"><div>在用数量：'+ data.zlonline +' </div><div>空闲数量：'+data.zlgunCount+'</div></div></div>';
                        }
                        if(data.type=="交流"){
                            mContent  += '<div class="infowdz_jlbox clearfix"> <div class="infowdz_zlboxL"><div>站点类型：'+data.type+' </div><div>充电枪数：'+ data.jlstakeCount +' </div> </div> <div class="infowdz_zlboxR"><div>在用数量：' + data.jlonline +' </div><div>空闲数量：'+ data.jlgunCount +' </div></div></div>';
                        }
                        if(data.type=="混合"){
                            mContent  += '<div class="infowdz_hhbox"> <div class="infowdz_hhbox_l"><div>直流 </div><div>充电枪数：' + data.zlstakeCount +' </div><div>在用数量：'+ data.zlonline +' </div><div>空闲数量：'+data.zlgunCount+' </div> </div> <div class="infowdz_hhbox_r"><div >交流 </div><div>充电枪数：'+ data.jlstakeCount +' </div><div>在用数量：' + data.jlonline +'  </div><div>空闲数量：'+ data.jlgunCount +' </div></div></div>';
                        }
                        mContent +='<div class="infowdz_address">'+address+'</div></div>'
                    infoWindow.setContent(mContent);
                    infoWindow_id = data.id
                    infoWindow.setPosition(new AMap.LngLat(data.lng, data.lat))
                        //判断是否打开infoWindow窗体
                    if (flag) {
                        infoWindow.open(map)
                        map.setZoomAndCenter(16, new AMap.LngLat(data.lng, data.lat))
                    }
                });

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // 状态码
                console.log(XMLHttpRequest.status);
                // 状态
                console.log(XMLHttpRequest.readyState);
                // 错误信息   
                console.log(textStatus);
            }
        })
    }


    function openGDInfo_refresh_new(data, node) {
        var parentNode = node.getParentNode();
        var companyName = parentNode.NAME;
        var plateNumber = node.NAME;
        var isonline = data.type;
        var locationDate = data.businessTime;
        $("#infoWindow_companyName").html(companyName);
        $("#infoWindow_plateNumber").html(plateNumber);
        $("#infoWindow_vehicleType").html(data.num);
        $("#onlineSpan").html(isonline);
        $("#zstakeCount").html(data.zlstakeCount);
        $("#zgunCount").html(data.zlgunCount);
        $("#zonlineCount").html(data.zlgunCount);
        $("#jstakeCount").html(data.jlstakeCount);
        $("#jgunCount").html(data.jlgunCount);
        $("#jonlineCount").html(data.jlgunCount);
        $("#locationDateSpan").html(locationDate);

        var lnglatArray = data.l.split(",");
        var llt = new AMap.LngLat(lnglatArray[0], lnglatArray[1]);
        infoWindow.setPosition(llt)
        geocoder.getAddress(llt, function(status, result) {
            if (status === 'complete' && result.info === 'OK') {
                address = result.regeocode.formattedAddress;

            } else {
                address = '地址解析失败'
                layer.msg('地址解析失败')
            }
            $("#addressSpan").html(address);
        });
        map.setZoomAndCenter(16, llt)
            //判断是否继续追踪这辆车
        if ($("#flow").hasClass("flow-active")) {
            map.setZoomAndCenter(17, llt)
        }

        if (data.imei) {
            if (data.line == '1') {
                $("#voiWid").removeAttr("disabled");
                $("#sendVoiceWindow").removeAttr("disabled");
                $("#shoot").removeAttr("disabled");
                $("#live").removeAttr("disabled");
                $("#retrieve").removeAttr("disabled");
            } else {
                $("#voiWid").attr("disabled", "disabled");
                $("#sendVoiceWindow").attr("disabled", "disabled");
                $("#shoot").attr("disabled", "disabled");
                $("#live").attr("disabled", "disabled");
                $("#retrieve").removeAttr("disabled");
            }
        } else {
            $("#voiWid").attr("disabled", "disabled");
            $("#sendVoiceWindow").attr("disabled", "disabled");
            $("#shoot").attr("disabled", "disabled");
            $("#live").attr("disabled", "disabled");
            $("#retrieve").attr("disabled", "disabled");
        }

    }


    //5s刷新infoWindow信息
    function openGDInfo_refresh(id, lnglat) {
        var address = ""
        $.ajax({
            url: ctx + 'monitorCenter/getBusPopInfo',
            type: 'post',
            ansyc: false,
            data: { id: id },
            dataType: 'json',
            complete: function(XHR, TS) {
                XHR = null;
            },
            success: function(data) {
                var vehicle = "";
                var isCarried = "";
                //获取后视镜是否在线
                var isonline = "";
                var isOnlineValue = "";
                var driverMsg = "";
                if (data.driverName != null && data.driverName != "") {
                    driverMsg = data.driverName;
                } else {
                    driverMsg = "暂无驾驶员信息";
                }
                var terminalType = "";
                var sst = "style='font-size:12px;position:absolute;right:71px;width:75px;'";
                if (ifnull(data.phone)) {
                    sst = "style='font-size:12px;position:absolute;right:31px;'";
                }
                $("#infoWindow_companyName").html(data.companyName)
                $("#infoWindow_plateNumber").html(data.plateNumber)
                $("#infoWindow_vehicleType").html(vehicle)
                $("#onlineSpan").html(isonline)
                $("#zstakeCount").html(data.zlstakeCount);
                $("#zgunCount").html(data.zlgunCount);
                $("#zonlineCount").html(data.zlgunCount);
                $("#jstakeCount").html(data.jlstakeCount);
                $("#jgunCount").html(data.jlgunCount);
                $("#jonlineCount").html(data.jlgunCount);
                // $("#infoWindow_isCarried").html(isCarried)
                $("#infoWindow_driverName").html(driverMsg)
                $("#infoWindow_phone").html(ifnull(data.phone))
                $("#locationDateSpan").html(getFormatDate(data.date))

                if (data.imei) {
                    if (data.isonline == '1') {
                        $("#voiWid").removeAttr("disabled");
                        $("#sendVoiceWindow").removeAttr("disabled");
                        $("#shoot").removeAttr("disabled");
                        $("#live").removeAttr("disabled");
                        $("#retrieve").removeAttr("disabled");
                    } else {
                        $("#voiWid").attr("disabled", "disabled");
                        $("#sendVoiceWindow").attr("disabled", "disabled");
                        $("#shoot").attr("disabled", "disabled");
                        $("#live").attr("disabled", "disabled");
                        $("#retrieve").removeAttr("disabled");
                    }
                } else {
                    $("#voiWid").attr("disabled", "disabled");
                    $("#sendVoiceWindow").attr("disabled", "disabled");
                    $("#shoot").attr("disabled", "disabled");
                    $("#live").attr("disabled", "disabled");
                    $("#retrieve").attr("disabled", "disabled");
                }
                var llt = new AMap.LngLat(data.longitude, data.latitude);
                infoWindow.setPosition(llt)
                geocoder.getAddress(llt, function(status, result) {
                    if (status === 'complete' && result.info === 'OK') {
                        address = result.regeocode.formattedAddress;

                    } else {
                        address = '地址解析失败'
                        layer.msg('地址解析失败')
                    }
                    $("#addressSpan").html(address);
                });
                map.setZoomAndCenter(16, llt)
                    //判断是否继续追踪这辆车
                if ($("#flow").hasClass("flow-active")) {
                    map.setZoomAndCenter(17, llt)
                }
            }
        })
    }




    //地图放大
    $("#covers").on("click", function() {
            $(this).toggleClass("active");
            if ($(this).hasClass("active")) {
                parent.fullstart();
                $("#test .left_sraong").css("display", "none");
                $("#test").addClass("left-ztree-close");
                $("#right_content").removeClass("col-md-10").width($(window).width() - 32).css("float", "left");
                $('#clscreen').attr('src', ctx + 'res/framework/icons/smascren.png')
            } else {
                parent.fullend();
                $("#test .left_sraong").css("display", "block");
                $("#test").removeClass("left-ztree-close")
                $('#right_content').addClass('col-md-10').removeAttr("style");
                $('#clscreen').attr('src', ctx + 'res/framework/icons/full.png')
            }
        })
        //表格添加颜色
    $('#columnTable tbody').on('click', 'tr', function() {
            $(this).attr('id', 'trClass').siblings().attr('id', '');
        })
        //数据表格修改
        //表头固定
    var hes = $(window).height() * 0.2 - 14.4;
    //轨迹信息窗体
    var trailfixed = $('#columnTrail').DataTable({
        bAutoWidth: false,
        bLengthChange: false,
        searching: false,
        showing: false,
        fixedHeader: true,
        "ordering": false,
        scrollCollapse: true,
        scrollX: true,
        scrollY: 138,
        "info": false,
        "paging": false

    })
    //隐藏树结构图
    function fixPosition() {
        var top = document.documentElement.clientHeight / 2 - $("#left_arrow").outerHeight() / 2 + 'px';
        var left = $("#right_content").offset().left + 'px';
        $('#left_arrow').css('top', top);
        $('#left_arrow').css('left', left);
    }
    //左侧树结构数据开始加载
    $(function() {
        fixPosition();
        $('#left_arrow').click(function() {
            if ($('#left_arrow').hasClass('left')) {
                $('#test').css('display', 'none');
                fixPosition();
                $('#left_arrow').html('<img th:src="@{/res/framework/images/rightshousuo.gif}" alt=""/>');
                $('#left_arrow').removeClass('left');
                $(".col-md-10").removeClass().addClass('col-md-12');
            } else {
                $(".col-md-12").removeClass().addClass('col-md-10');
                $('#test').css('display', 'block');
                fixPosition();
                $('#left_arrow').html('<img th:src="@{/res/framework/images/leftshousuo.gif}" alt=""/>');
                $('#left_arrow').addClass('left');
            }
        });
        $('#downPull').click(function() {
            if ($(this).hasClass('bottom')) {
                $('#dataLoad').css('display', 'none');
                $('#container').css('height', '100%');
                $(this).removeClass('bottom');
                $('#up>img').attr('src', ctx + 'res/framework/icons/pull.png');
            } else {
                $('#container').css('height', '76%');
                $('#dataLoad').css('display', 'block');
                $('#downPull').addClass('bottom');
                $('#up>img').attr('src', ctx + 'res/framework/icons/updown.png');
            }
        });
        $('#downPull').trigger("click");
    })


    //定位提示框
    var infoWindow = new AMap.InfoWindow({
        // isCustom:true,
        offset: new AMap.Pixel(0, -30),
        autoMove: false,
        anchor: 'bottom-center',
    });;

    setTimeout(function() { $("#searchCar").trigger("click"); }, 400)
    $('#search-bt').click(function() {
        treeObj.cancelSelectedNode();
        infoWindow.close()
        var keyword = $("#keyword").val();
        if (keyword != null && keyword != "") {
            var node = treeObj.getNodesByFilter(zFilter, true)
            if (node) {
                treeObj.selectNode(node)
                var marker = markers.get(node.ID)
                if (marker) {
                    openGDInfo(marker.getExtData(), marker.getPosition(), true)
                } else {
                    layer.msg("该车辆没有定位信息!")
                }
            } else {
                layer.msg("没有查询到对应车辆信息!")
            }
        } else {
            layer.msg("请输入查询信息!")
        }
    });
    function zFilter(node) {
        var keyword = $("#keyword").val();
        return (node.TYPE != 'org' && node.NAME.indexOf(keyword) > -1);
    }


    //自适应左侧书高度
    var addressIdx = 0;

    function getAddressBatch() {
        var pt = lineArr[addressIdx];
        geocodeSearch(pt);
        addressIdx++;
    }

    function geocodeSearch(pt) {
        if (addressIdx < lineArr.length - 1) {
            setTimeout(window.getAddressBatch, 400);
        }
        geocoder.getAddress(pt, function(status, result) {
            if (status === 'complete' && result.info === 'OK') {
                var address = result.regeocode.formattedAddress;
                $("#addressTd" + (addressIdx - 1)).html(address);
            }
        });
    }

    function set_text_value_position(obj, spos) {
        var tobj = document.getElementById(obj);
        if (spos < 0)
            spos = tobj.value.length;
        if (tobj.setSelectionRange) { //兼容火狐,谷歌
            setTimeout(function() {
                tobj.setSelectionRange(spos, spos);
                tobj.focus();
            }, 0);
        } else if (tobj.createTextRange) { //兼容IE
            var rng = tobj.createTextRange();
            rng.move('character', spos);
            rng.select();
        }
    }